/*
 * @Description: 前世今生
 * @Author: zzj
 * @Date: 2021-09-09 14:21:40
 * @LastEditors: zzj
 * @LastEditTime: 2021-09-09 15:13:13
 */

/*
  前世今生:根据用户输入的名字，查找他的前世是谁。
  获取用户输入名字中的姓（字符串截取），从数据库/数组中查找相似的姓，提出名字，从中返回一个随机名字。
  例如数组：
  var arr = ["李世民","荆轲","后羿","刘邦","白起","白浅浅","李元芳","李白","刘备","刘禅","关羽","张飞","妲己","孙悟空","鲁班","安琪拉","刘亚瑟","程咬金","张无忌","张良"];
  当用户输入姓名“张三”，将会从“张飞”、“张无忌”、“张良”中随机返回一个名字。
 */

var arr = ["李世民","荆轲","后羿","刘邦","白起","白浅浅","李元芳","李白","刘备","刘禅","关羽","张飞","妲己","孙悟空","鲁班","安琪拉","刘亚瑟","程咬金","张无忌","张良"];
const readline = require('readline-sync')
var a = readline.question("请输入姓名：")
var reg = a.split("")[0];
var c = [];
for(k in arr){
    var b = (arr[k].split(""))[0];
    if (reg == b){
        c.push(arr[k]);
    }else{
        continue;
    }
}
var d = Math.floor(Math.random() * (c.length));
console.log(c[d]);

